package com.yanmaohu.yulia.bean;

/**
 * @author Bright Lee
 */
public final class TableExpression {

    private int beginIndex;
    private int endIndex;
    private FromClause fromClause;
    private WhereClause whereClause;
    private GroupByClause groupByClause;
    private HavingClause havingClause;
    private WindowClause windowClause;

    public TableExpression(FromClause fromClause,
                           WhereClause whereClause,
                           GroupByClause groupByClause,
                           HavingClause havingClause,
                           WindowClause windowClause) {
        beginIndex = fromClause.getBeginIndex();
        endIndex = fromClause.getEndIndex();
        if (whereClause != null) {
            endIndex = whereClause.getEndIndex();
        }
        if (groupByClause != null) {
            endIndex = groupByClause.getEndIndex();
        }
        if (havingClause != null) {
            endIndex = havingClause.getEndIndex();
        }
        if (groupByClause != null) {
            endIndex = windowClause.getEndIndex();
        }
        this.fromClause = fromClause;
        this.whereClause = whereClause;
        this.groupByClause = groupByClause;
        this.havingClause = havingClause;
        this.windowClause = windowClause;
    }

    public int getBeginIndex() {
        return beginIndex;
    }

    public int getEndIndex() {
        return endIndex;
    }

    public FromClause getFromClause() {
        return fromClause;
    }

    public WhereClause getWhereClause() {
        return whereClause;
    }

    public GroupByClause getGroupByClause() {
        return groupByClause;
    }

    public HavingClause getHavingClause() {
        return havingClause;
    }

    public WindowClause getWindowClause() {
        return windowClause;
    }

}
